<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>lwIP: SMTP client</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">lwIP
   &#160;<span id="projectnumber">2.1.2</span>
   </div>
   <div id="projectbrief">Lightweight IP stack</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('group__smtp.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#groups">Modules</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">SMTP client<div class="ingroups"><a class="el" href="group__apps.html">Applications</a></div></div>  </div>
</div><!--header-->
<div class="contents">
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="groups"></a>
Modules</h2></td></tr>
<tr class="memitem:group__smtp__opts"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__smtp__opts.html">Options</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ga1ccf4305461ec16cf41599341ec54983"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__infrastructure__errors.html#gaf02d9da80fd66b4f986d2c53d7231ddb">err_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__smtp.html#ga1ccf4305461ec16cf41599341ec54983">smtp_set_server_addr</a> (const char *server)</td></tr>
<tr class="separator:ga1ccf4305461ec16cf41599341ec54983"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga4b0606e7ad64d8215cebbea43f08759f"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__smtp.html#ga4b0606e7ad64d8215cebbea43f08759f">smtp_set_server_port</a> (u16_t port)</td></tr>
<tr class="separator:ga4b0606e7ad64d8215cebbea43f08759f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gae72a8a0ec42ecae1be401978e224c39e"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__smtp.html#gae72a8a0ec42ecae1be401978e224c39e">smtp_set_tls_config</a> (struct altcp_tls_config *tls_config)</td></tr>
<tr class="separator:gae72a8a0ec42ecae1be401978e224c39e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga79567a5a75e048a6b8addb5b038fc899"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__infrastructure__errors.html#gaf02d9da80fd66b4f986d2c53d7231ddb">err_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__smtp.html#ga79567a5a75e048a6b8addb5b038fc899">smtp_set_auth</a> (const char *username, const char *pass)</td></tr>
<tr class="separator:ga79567a5a75e048a6b8addb5b038fc899"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gae43119480c4146df9eeff7ae80c767f7"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__infrastructure__errors.html#gaf02d9da80fd66b4f986d2c53d7231ddb">err_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__smtp.html#gae43119480c4146df9eeff7ae80c767f7">smtp_send_mail</a> (const char *from, const char *to, const char *subject, const char *body, smtp_result_fn callback_fn, void *callback_arg)</td></tr>
<tr class="separator:gae43119480c4146df9eeff7ae80c767f7"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga06f6582701def2a62582373bb0be5788"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__infrastructure__errors.html#gaf02d9da80fd66b4f986d2c53d7231ddb">err_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__smtp.html#ga06f6582701def2a62582373bb0be5788">smtp_send_mail_static</a> (const char *from, const char *to, const char *subject, const char *body, smtp_result_fn callback_fn, void *callback_arg)</td></tr>
<tr class="separator:ga06f6582701def2a62582373bb0be5788"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaa9331cc8c6d73a8cd7e6e4466aca9243"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__smtp.html#gaa9331cc8c6d73a8cd7e6e4466aca9243">smtp_send_mail_int</a> (void *arg)</td></tr>
<tr class="separator:gaa9331cc8c6d73a8cd7e6e4466aca9243"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<p>This is simple SMTP client for raw API. It is a minimal implementation of SMTP as specified in RFC 5321.</p>
<p>Example usage: </p><div class="fragment"><div class="line"><span class="keywordtype">void</span> my_smtp_result_fn(<span class="keywordtype">void</span> *arg, u8_t smtp_result, u16_t srv_err, <a class="code" href="group__infrastructure__errors.html#gaf02d9da80fd66b4f986d2c53d7231ddb">err_t</a> err)</div><div class="line">{</div><div class="line">  printf(<span class="stringliteral">&quot;mail (%p) sent with results: 0x%02x, 0x%04x, 0x%08x\n&quot;</span>, arg,</div><div class="line">         smtp_result, srv_err, err);</div><div class="line">}</div><div class="line"><span class="keyword">static</span> <span class="keywordtype">void</span> my_smtp_test(<span class="keywordtype">void</span>)</div><div class="line">{</div><div class="line">  <a class="code" href="group__smtp.html#ga1ccf4305461ec16cf41599341ec54983">smtp_set_server_addr</a>(<span class="stringliteral">&quot;mymailserver.org&quot;</span>);</div><div class="line">  -&gt; <span class="keyword">set</span> both username and password as NULL <span class="keywordflow">if</span> no auth needed</div><div class="line">  <a class="code" href="group__smtp.html#ga79567a5a75e048a6b8addb5b038fc899">smtp_set_auth</a>(<span class="stringliteral">&quot;username&quot;</span>, <span class="stringliteral">&quot;password&quot;</span>);</div><div class="line">  <a class="code" href="group__smtp.html#gae43119480c4146df9eeff7ae80c767f7">smtp_send_mail</a>(<span class="stringliteral">&quot;sender&quot;</span>, <span class="stringliteral">&quot;recipient&quot;</span>, <span class="stringliteral">&quot;subject&quot;</span>, <span class="stringliteral">&quot;body&quot;</span>, my_smtp_result_fn,</div><div class="line">                 some_argument);</div><div class="line">}</div></div><!-- fragment --><p>When using from any other thread than the tcpip_thread (for NO_SYS==0), use <a class="el" href="group__smtp.html#gaa9331cc8c6d73a8cd7e6e4466aca9243">smtp_send_mail_int()</a>!</p>
<p>SMTP_BODYDH usage: </p><div class="fragment"><div class="line"><span class="keywordtype">int</span> my_smtp_bodydh_fn(<span class="keywordtype">void</span> *arg, <span class="keyword">struct</span> smtp_bodydh *bdh)</div><div class="line">{</div><div class="line">   <span class="keywordflow">if</span>(bdh-&gt;state &gt;= 10) {</div><div class="line">      <span class="keywordflow">return</span> BDH_DONE;</div><div class="line">   }</div><div class="line">   sprintf(bdh-&gt;buffer,<span class="stringliteral">&quot;Line #%2d\r\n&quot;</span>,bdh-&gt;state);</div><div class="line">   bdh-&gt;length = strlen(bdh-&gt;buffer);</div><div class="line">   ++bdh-&gt;state;</div><div class="line">   <span class="keywordflow">return</span> BDH_WORKING;</div><div class="line">}</div><div class="line"></div><div class="line">smtp_send_mail_bodycback(<span class="stringliteral">&quot;sender&quot;</span>, <span class="stringliteral">&quot;recipient&quot;</span>, <span class="stringliteral">&quot;subject&quot;</span>, </div><div class="line">               my_smtp_bodydh_fn, my_smtp_result_fn, some_argument);</div></div><!-- fragment --><h2 class="groupheader">Function Documentation</h2>
<a id="gae43119480c4146df9eeff7ae80c767f7"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gae43119480c4146df9eeff7ae80c767f7">&#9670;&nbsp;</a></span>smtp_send_mail()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__infrastructure__errors.html#gaf02d9da80fd66b4f986d2c53d7231ddb">err_t</a> smtp_send_mail </td>
          <td>(</td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>from</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>to</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>subject</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>body</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">smtp_result_fn&#160;</td>
          <td class="paramname"><em>callback_fn</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>callback_arg</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Send an email via the currently selected server, username and password.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">from</td><td>source email address (must be NULL-terminated) </td></tr>
    <tr><td class="paramname">to</td><td>target email address (must be NULL-terminated) </td></tr>
    <tr><td class="paramname">subject</td><td>email subject (must be NULL-terminated) </td></tr>
    <tr><td class="paramname">body</td><td>email body (must be NULL-terminated) </td></tr>
    <tr><td class="paramname">callback_fn</td><td>callback function </td></tr>
    <tr><td class="paramname">callback_arg</td><td>user argument to callback_fn </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>- ERR_OK if structures were allocated and no error occured starting the connection (this does not mean the email has been successfully sent!)<ul>
<li>another err_t on error. </li>
</ul>
</dd></dl>

</div>
</div>
<a id="gaa9331cc8c6d73a8cd7e6e4466aca9243"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaa9331cc8c6d73a8cd7e6e4466aca9243">&#9670;&nbsp;</a></span>smtp_send_mail_int()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void smtp_send_mail_int </td>
          <td>(</td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>arg</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Same as smtp_send_mail but takes a struct <a class="el" href="structsmtp__send__request.html">smtp_send_request</a> as single parameter which contains all the other parameters. To be used with tcpip_callback to send mail from interrupt context or from another thread.</p>
<p>WARNING: server and authentication must stay untouched until this function has run!</p>
<p>Usage example:</p><ul>
<li>allocate a struct <a class="el" href="structsmtp__send__request.html">smtp_send_request</a> (in a way that is allowed in interrupt context)</li>
<li>fill the members of the struct as if calling smtp_send_mail</li>
<li>specify a callback_function</li>
<li>set callback_arg to the structure itself</li>
<li>call this function</li>
<li>wait for the callback function to be called</li>
<li>in the callback function, deallocate the structure (passed as arg) </li>
</ul>

</div>
</div>
<a id="ga06f6582701def2a62582373bb0be5788"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga06f6582701def2a62582373bb0be5788">&#9670;&nbsp;</a></span>smtp_send_mail_static()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__infrastructure__errors.html#gaf02d9da80fd66b4f986d2c53d7231ddb">err_t</a> smtp_send_mail_static </td>
          <td>(</td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>from</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>to</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>subject</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>body</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">smtp_result_fn&#160;</td>
          <td class="paramname"><em>callback_fn</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>callback_arg</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Same as smtp_send_mail, but doesn't copy from, to, subject and body into an internal buffer to save memory. WARNING: the above data must stay untouched until the callback function is called (unless the function returns != ERR_OK) </p>

</div>
</div>
<a id="ga79567a5a75e048a6b8addb5b038fc899"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga79567a5a75e048a6b8addb5b038fc899">&#9670;&nbsp;</a></span>smtp_set_auth()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__infrastructure__errors.html#gaf02d9da80fd66b4f986d2c53d7231ddb">err_t</a> smtp_set_auth </td>
          <td>(</td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>username</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>pass</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Set authentication parameters for next SMTP connection</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">username</td><td>login name as passed to the server </td></tr>
    <tr><td class="paramname">pass</td><td>password passed to the server together with username </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="ga1ccf4305461ec16cf41599341ec54983"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga1ccf4305461ec16cf41599341ec54983">&#9670;&nbsp;</a></span>smtp_set_server_addr()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__infrastructure__errors.html#gaf02d9da80fd66b4f986d2c53d7231ddb">err_t</a> smtp_set_server_addr </td>
          <td>(</td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>server</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Set IP address or DNS name for next SMTP connection</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">server</td><td>IP address (in ASCII representation) or DNS name of the server </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="ga4b0606e7ad64d8215cebbea43f08759f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga4b0606e7ad64d8215cebbea43f08759f">&#9670;&nbsp;</a></span>smtp_set_server_port()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void smtp_set_server_port </td>
          <td>(</td>
          <td class="paramtype">u16_t&#160;</td>
          <td class="paramname"><em>port</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Set TCP port for next SMTP connection</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">port</td><td>TCP port </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="gae72a8a0ec42ecae1be401978e224c39e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gae72a8a0ec42ecae1be401978e224c39e">&#9670;&nbsp;</a></span>smtp_set_tls_config()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void smtp_set_tls_config </td>
          <td>(</td>
          <td class="paramtype">struct altcp_tls_config *&#160;</td>
          <td class="paramname"><em>tls_config</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Set TLS configuration for next SMTP connection</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">tls_config</td><td>TLS configuration </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.13 </li>
  </ul>
</div>
</body>
</html>
